﻿#include "menu.h"

#include <QJsonArray>
#include <QMetaProperty>
#include <QVariantMap>

Menu::Menu(QObject *parent): QBaseEntity(parent)
{
    clear();
    const QMetaObject *metaObject = this->metaObject();
    setTableName(QString(metaObject->className()).toLower());
    setPrimaryKey("id");
    setDefaultValue("parentId",0);
//    setIgnoreKeys(QStringList() << "username");
//    setUniqueKeys(QStringList() << "title");
    setNotNullKeys(QStringList() << "title"<<"path" << "authority");
    setDefaultValue("authority",QString("admin"));
    setDefaultValue("keepAlive",true);
}

Menu::Menu(uint64_t m_id, QString m_name, QString m_path, QString m_redirect, QString m_component, uint64_t m_parentId, QString m_icon, uint32_t m_order, QString m_title,QStringList m_athority)
{
    clear();
    const QMetaObject *metaObject = this->metaObject();
    setTableName(QString(metaObject->className()).toLower());
    setPrimaryKey("id");
    setDefaultValue("parentId",0);
//    setIgnoreKeys(QStringList() << "username");
//    setUniqueKeys(QStringList() << "title");
    setNotNullKeys(QStringList() << "title"<<"path" << "authority");
    setDefaultValue("authority",QString("admin"));
    id = m_id;
    name = m_name;
    path = m_path;
    redirect = m_redirect;
    component = m_component;
    parentId = m_parentId;
    icon = m_icon;
    order = m_order;
    title = m_title;
    authority = m_athority;
}

Menu::~Menu()
{

}

uint64_t Menu::getId() const
{
    return id;
}

void Menu::setId(const uint64_t &value)
{
    id = value;
}

QString Menu::getName() const
{
    return name;
}

void Menu::setName(const QString &value)
{
    name = value;
}

QString Menu::getPath() const
{
    return path;
}

void Menu::setPath(const QString &value)
{
    path = value;
}

QString Menu::getRedirect() const
{
    return redirect;
}

void Menu::setRedirect(const QString &value)
{
    redirect = value;
}

QString Menu::getComponent() const
{
    return component;
}

void Menu::setComponent(const QString &value)
{
    component = value;
}

uint64_t Menu::getParentId() const
{
    return parentId;
}

void Menu::setParentId(const uint64_t &value)
{
    parentId = value;
}

QString Menu::getActiveIcon() const
{
    return activeIcon;
}

void Menu::setActiveIcon(const QString &value)
{
    activeIcon = value;
}

QString Menu::getActivePath() const
{
    return activePath;
}

void Menu::setActivePath(const QString &value)
{
    activePath = value;
}

bool Menu::getAffixTab() const
{
    return affixTab;
}

void Menu::setAffixTab(bool value)
{
    affixTab = value;
}

int32_t Menu::getAffixTabOrder() const
{
    return affixTabOrder;
}

void Menu::setAffixTabOrder(const int32_t &value)
{
    affixTabOrder = value;
}

QStringList Menu::getAuthority() const
{
    return authority;
}

void Menu::setAuthority(const QStringList &value)
{
    authority = value;
}

void Menu::appendAuthority(const QStringList &value)
{
    authority.append(value);
}

void Menu::appendAuthority(const QString &value)
{
    authority.append(value);
}

QString Menu::getBadge() const
{
    return badge;
}

void Menu::setBadge(const QString &value)
{
    badge = value;
}

QString Menu::getBadgeType() const
{
    return badgeType;
}

void Menu::setBadgeType(const QString &value)
{
    badgeType = value;
}

QString Menu::getBadgeVariants() const
{
    return badgeVariants;
}

void Menu::setBadgeVariants(const QString &value)
{
    badgeVariants = value;
}

bool Menu::getHideChildrenInMenu() const
{
    return hideChildrenInMenu;
}

void Menu::setHideChildrenInMenu(bool value)
{
    hideChildrenInMenu = value;
}

bool Menu::getHideInBreadcrumb() const
{
    return hideInBreadcrumb;
}

void Menu::setHideInBreadcrumb(bool value)
{
    hideInBreadcrumb = value;
}

bool Menu::getHideInMenu() const
{
    return hideInMenu;
}

void Menu::setHideInMenu(bool value)
{
    hideInMenu = value;
}

bool Menu::getHideInTab() const
{
    return hideInTab;
}

void Menu::setHideInTab(bool value)
{
    hideInTab = value;
}

QString Menu::getIcon() const
{
    return icon;
}

void Menu::setIcon(const QString &value)
{
    icon = value;
}

QString Menu::getIframeSrc() const
{
    return iframeSrc;
}

void Menu::setIframeSrc(const QString &value)
{
    iframeSrc = value;
}

bool Menu::getIgnoreAccess() const
{
    return ignoreAccess;
}

void Menu::setIgnoreAccess(bool value)
{
    ignoreAccess = value;
}

bool Menu::getKeepAlive() const
{
    return keepAlive;
}

void Menu::setKeepAlive(bool value)
{
    keepAlive = value;
}

QString Menu::getLink() const
{
    return link;
}

void Menu::setLink(const QString &value)
{
    link = value;
}

bool Menu::getLoaded() const
{
    return loaded;
}

void Menu::setLoaded(bool value)
{
    loaded = value;
}

int32_t Menu::getMaxNumOfOpenTab() const
{
    return maxNumOfOpenTab;
}

void Menu::setMaxNumOfOpenTab(const int32_t &value)
{
    maxNumOfOpenTab = value;
}

bool Menu::getMenuVisibleWithForbidden() const
{
    return menuVisibleWithForbidden;
}

void Menu::setMenuVisibleWithForbidden(bool value)
{
    menuVisibleWithForbidden = value;
}

bool Menu::getOpenInNewWindow() const
{
    return openInNewWindow;
}

void Menu::setOpenInNewWindow(bool value)
{
    openInNewWindow = value;
}

int32_t Menu::getOrder() const
{
    return order;
}

void Menu::setOrder(const int32_t &value)
{
    order = value;
}

QString Menu::getQuery() const
{
    return query;
}

void Menu::setQuery(const QString &value)
{
    query = value;
}

QString Menu::getTitle() const
{
    return title;
}

void Menu::setTitle(const QString &value)
{
    title = value;
}

